********************************
***Fix Message Vary Source***
********************************

clear all

********************
*Set Person Working*
*Change this to your name!!!!!
********************
*global carolina 0
*global emily 1

global emily 1
global carolina 0

*********************
*Load Files*
*********************

*Carolina's Computer*
if $carolina ==1  {
cap cd "~\Dropbox\Carolina-Emily-Project\Data\Study"
global out "..\..\Results\"
}


if $emily ==1  {
*Emily's Computer*
cap cd "~/Dropbox/SourceContent/Data/Study"
global out "../../Results/"
global draftout "../../Draft/Figures/"
} 

use 3_clean_data, replace

*********************************
***Create Variables and Format***
*********************************
	
global lasso0 hispanic age55_64 candidate16_hillary candidate16_other ///
	immlevel_decrease gun_lessstrict abortion_illegal tax_toohigh health_notgvt ///
	occ_twitter occ_buzzfeed trumpfan lebronfan taylorfan bgatesfan ///
	obamafan obama_neutral topissue_health 
	
global lasso1 black hispanic age35_44 age45_54 hsdegree ///
	candidate16_hillary immlevel_decrease immlevel_same ///
	gun_same gun_lessstrict abortion_partlegal abortion_illegal tax_toohigh ///
	health_neutral health_notgvt i.freq_nytimes ///
	daily_tv occ_tv daily_newspaper i.freq_fox week_breitbart ///
	daily_breitbart occ_buzzfeed ///
	lebron_neutral obamafan trump_neutral trumpfan west topissue_tax 
	

	
gen group1=treatment==5 | treatment==7 | treatment==0
gen group2=treatment==6 | treatment==8 | treatment==0
gen group3=treatment==1 | treatment==3 | treatment==0
gen group4=treatment==2 | treatment==4 | treatment==0

global message1 "Anti"
global message2 "Anti"
global message3 "Pro"
global message4 "Pro"

global source1 "Trump"
global source2 "Obama"
global source3 "Trump"
global source4 "Obama" 

gen president=treatment==1 | treatment==2 | treatment==5 | treatment==6
gen actor=treatment==3 | treatment==4 | treatment==7 | treatment==8
gen turkey= treatment==9 | treatment==10
gen priming=turkey==1 | president==1
gen message=actor==1 | president==1


*****************************
*****************************
*****************************

global color1 "blue"
global color0 "red"
global party0 "Republicans"
global party1 "Democrats"
global dir0 "anti"
global dir1 "pro"

**************************************************
*CREATE PLOTS OF RESULTS - CONVINCED MORE BY PRESIDENT*
**************************************************

/*President vs. Actor vs. No-Audio*
4 Messages:
Anti-Immigrant (Trump)
Anti-Immigrant (Obama)
Pro-Immigrant (Trump)
Pro-Immigrant (Obama)
2 Graphs: 
Republicans
Democrats
*/

foreach p in 0 1 {
	gen b1`p'=.
	gen b2`p'=.
}


gen n=_n

foreach p in 0 1 {

local n=0
	
foreach y in 1 2 3 4 {
	
	local n=`n'+1
 
	reg ln1_prob_index_${dir`p'} president message ${lasso`p'} ///
		if (group`y'==1) & recruit==`p', robust  

	sum prob_index_${dir`p'} if e(sample)==1 & treat==0
	local m=r(mean)
	local b1=_b[message]*(`m'+1)/`m'*100
	local b2=_b[president]*(`m'+1)/`m'*100
	replace b1`p'=`b1' if n==`n'
	replace b2`p'=`b2' if n==`n'
		
	}
	}
	
	
*Labels*
label define ta 1 `" "Anti" "Trump" " " "' 2 `" "Anti" "Obama" " " "' ///
	3 `" "Pro" "Trump" " " "' 4 `" "Pro" "Obama" " " "', replace 

label values n ta
	

foreach p in 0 1 {

*President vs. Actor*
# delimit ;

graph bar b1`p' b2`p' if n<5, over(n) stack	
	bar(1, color(black))
	bar(2, color(white) lcolor(black)) 
	blabel(bar, format(%6.2f) position(outside) size(vsmall))
	bargap(0.5)
	graphregion(color(white)) 
	yline(0, lcolor(gray))
	ylabel(, nogrid)
	ytitle("% Change in Probability" " ")
	legend(order(1 "Anonymous Message" 2 "Source Persuasion" ) rows(2))
	ylabel(-10(2)6, nogrid )
	yscale(range(-10(2)6))
	xsize(6) ysize(5) 
	;
	# delimit cr

graph export "$draftout/6_Bar_MessageFixed_VarySource_${party`p'}.eps", replace	

}












